module.exports = class extends think.Model {
  queryData({
    page = 1,
    limit = 10,
    title = '',
    adTypeId = 0,
    field = '*',
    order = '',
    platformId = 0
  }) {
    const where = {
      platform_id: platformId,
      status: 1
    };
    if (title) {
      where.title = ['like', `%${title}%`];
    }
    if (adTypeId > 0) {
      where.ad_type_id = adTypeId;
    }
    if (order) {
      this.order(order);
    }
    return this.where(where).page(page, limit).field(field).select();
  }

  updateById(platformId, id, data) {
    return this.where({
      id,
      platform_id: platformId
    }).update(data);
  }
  removeById(platformId, id) {
    return this.where({
      platform_id: platformId,
      id
    }).delete();
  }
};
